package zero.tech.games.gateway.config;

import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange;

import com.alibaba.fastjson.JSONObject;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import zero.tech.core.data.Resp;

public class MonoUtil {
	public static Mono<Void> getVoidMono(ServerWebExchange exchange,Resp resp) {
		ServerHttpResponse response=exchange.getResponse();
		response.getHeaders().add("Content-Type", "application/json;charset=UTF-8");
		DataBuffer dataBuffer=response.bufferFactory().wrap(JSONObject.toJSONString(resp).getBytes());
		return response.writeWith(Flux.just(dataBuffer));
	}
}
